app.inventory = {
	init : function() {
		
	}
};

var Inventory = function(size) {
	var _items = [];
	var _count = 0;
	var _size = size || 50;
	
	this.put = function(item, amount) {
		if (_items[item.id]) {
			_items[item.id].amount += amount;
		}
		else {
			_items[item.id] = {
				item : item,
				amount : amount
			}
			
			_count++;
		}
	};
	
	this.get = function(id, amount) {
		var item = _items[id];
		var item2get = {
			item : null,
			amount : 0
		};
		
		if (!item) {
			return false;
		}
		
		item2get.item = item.item;
		item2get.amount = item.amount < amount ? item.amount : amount;
		item.amount -= amount;
		
		if (item.amount <= 0) {
			delete item;
			_count--;
		}
		
		return item2get;
	};
	
	this.setSize = function(size) {
		if (_count > size) {
			return false;
		}
		
		return _size = size;
	};
	
	this.arrange = function() {}
}

app.InventoryFactory = {
	create : function(sizeX, sizeY) {
		
	}
};